package com.fanghuyun.iswaf.filter;

import java.util.EnumSet;
import java.util.logging.Logger;
import javax.servlet.DispatcherType;
import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class IsWafListener implements ServletContextListener{

	private Logger logger = Logger.getLogger("iswaf");
	
	public void contextDestroyed(ServletContextEvent arg0) {
		logger.info("Context Destroyed......");
	}

	public void contextInitialized(ServletContextEvent sce) {
		ServletContext sc = sce.getServletContext();
		FilterRegistration.Dynamic filter = sc.addFilter("IsWafFilter","com.fanghuyun.iswaf.filter.IsWafFilter");
		EnumSet<DispatcherType> disps = EnumSet.of(DispatcherType.REQUEST,DispatcherType.FORWARD);
		filter.addMappingForUrlPatterns(disps, true, "/*");
	}
	
}
